package com.aube.rvi.util;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;


public class Utils {
	
    public static final String sTAG = Utils.class.getSimpleName();
 
    public static enum LogType{
    	DEBUG,
    	ERROR,
    	INFO,
    	WARE
    }

    public static void sysout(String msg){
    	if(Constant.DEBUG){
    		System.out.println(msg);
    	}
    }
    
    public static void showToast(Context context, String msg) {
		makeToast(context, msg).show();
    }
    
    public static void showToast(Context context, int resId) {
		makeToast(context, context.getResources().getString(resId)).show();
    }

	public static Toast mToast;

	private static Toast makeToast(Context context, String txt) {
		if(mToast == null)
			mToast = Toast.makeText(context.getApplicationContext(), txt, Toast.LENGTH_SHORT);
		else
			mToast.setText(txt);
		return mToast;
	}
    
    public static void Log(String msg) {
		if (!Constant.DEBUG) {
			return;
		}
        Log.i("com.aube", msg);
    }
    
    public static void Log(String TAG, String msg) {
        if (null == TAG) {
            TAG = sTAG;
        }
        if (!Constant.DEBUG) {
            return;
        }
        Log.i(TAG, msg);
    }
    
    public static void Log(LogType logType,String TAG, String msg) {
        if (null == TAG) {
            TAG = sTAG;
        }
        if (!Constant.DEBUG) {
            return;
        }
        if(LogType.DEBUG.compareTo(logType) == 0){
        	Log.d(TAG, msg);
        }else if(LogType.ERROR.compareTo(logType) == 0){
        	Log.e(TAG, msg);
        }else if(LogType.INFO.compareTo(logType) == 0){
        	Log.i(TAG, msg);
        }else if(LogType.WARE.compareTo(logType) == 0){
        	Log.w(TAG, msg);
        }else{
        	Log.i(TAG, msg);
        }
    }

}
